package cn.codeartist.springboot.component.rocketmq.proxy;

import cn.codeartist.springboot.component.rocketmq.callback.SuccessSendCallback;
import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.TransactionSendResult;
import org.apache.rocketmq.common.message.MessageQueue;

import java.util.Collection;

/**
 * RocketMQ生产者发送消息接口
 *
 * @author 艾江南
 * @date 2020/8/11
 */
public interface RocketMQProducer {

    /*
     * Single
     */

    SendResult send(MessageEntity msg);

    void sendAsync(MessageEntity msg);

    void sendAsync(MessageEntity msg, SuccessSendCallback sendCallback);

    void sendOneWay(MessageEntity msg);

    SendResult send(MessageEntity msg, MessageQueue mq);

    void sendAsync(MessageEntity msg, MessageQueue mq);

    void sendAsync(MessageEntity msg, MessageQueue mq, SuccessSendCallback sendCallback);

    void sendOneWay(MessageEntity msg, MessageQueue mq);

    SendResult send(MessageEntity msg, MessageQueueSelector selector, Object arg);

    void sendAsync(MessageEntity msg, MessageQueueSelector selector, Object arg);

    void sendAsync(MessageEntity msg, MessageQueueSelector selector, Object arg, SuccessSendCallback sendCallback);

    void sendOneWay(MessageEntity msg, MessageQueueSelector selector, Object arg);

    TransactionSendResult sendMessageInTransaction(MessageEntity msg, LocalTransactionExecuter tranExecutor, Object arg);

    /*
     * Batch
     */

    void send(Collection<MessageEntity> msgs);

    void send(Collection<MessageEntity> msgs, long timeout);

    void send(Collection<MessageEntity> msgs, MessageQueue mq);

    void send(Collection<MessageEntity> msgs, MessageQueue mq, long timeout);
}
